<?php 
$callback = $_GET["jsoncallback"];
$url = $_GET["url"];
$tryTimes = 3;
if(isset($_GET["tryTimes"]))
{
	$tryTimes = $_GET["tryTimes"];
}
header('Content-type: application/x-javascript');
$lines_string = "";

if($callback)
{
	echo $callback . "(";
	if($url)
	{
		$ch=curl_init(); 
		$timeout=3; 
		curl_setopt($ch, CURLOPT_URL, $url); 
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
		for($i = 0; $i < $tryTimes; $i++)
		{
			$lines_string=curl_exec($ch);
			
			if(strlen($lines_string) > 5)
			{
				break;
			}
			usleep(100 * 1000);//100ms		
		}
		curl_close($ch);
		if(strlen($lines_string) == 0)
		{
			echo "[]";
		}
		else
		{
			echo $lines_string;
		}
		
	}
	echo ")";
}
?>